// Created by WXX on 2022/1/18 10:09
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

/**
 * 执行用时：16 ms, 在所有 C++ 提交中击败了33.81%的用户
 * 内存消耗：13.3 MB, 在所有 C++ 提交中击败了34.35%的用户
 */
class Solution {
public:
    int findMinDifference(vector<string> &timePoints) {
        vector<int> q;
        for (auto t : timePoints) {
            int h, m;
            sscanf(t.c_str(), "%d:%d", &h, &m);
            q.push_back(h * 60 + m);
        }
        sort(q.begin(), q.end());
        int res = INT_MAX;
        for (int i = 1; i < q.size(); i++) res = min(res, q[i] - q[i - 1]);
        res = min(res, 24 * 60 + q[0] - q.back());
        return res;
    }
};

int main() {

    vector<string> timePoints = {"00:00", "23:59", "00:00"};
    cout << Solution().findMinDifference(timePoints) << endl;  // 0

    return 0;
}
